import { useStore, StoreApi } from 'zustand'
const createBoundedUseStore = ((store) => (selector) => useStore(store)) as <
    S extends StoreApi<unknown>,
>(
    store: S,
) => {
    (): ExtractState<S>
    <T>(selector: (state: ExtractState<S>) => T): T
}

type ExtractState<S> = S extends { getState: () => infer X } ? X : never;

export default createBoundedUseStore;
